function e(e, t, a) {
    return t in e ? Object.defineProperty(e, t, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = a, e;
}

var t = getApp(), a = require("../../utils/api.js"), o = require("../../wxParse/wxParse.js");

Page({
    data: {
        status: 0
    },
    onLoad: function(e) {
        var t = this, a = e.id, s = e.type, n = getCurrentPages(), i = (n[n.length - 1], 
        n[n.length - 2]), l = (n[n.length - 3], i.data), r = i.data.money;
        if (console.log(r), "noget" == s) {
            u = l.info;
            t.setData({
                status: 1
            });
        } else if ("isget" == s) {
            u = l.is_get;
            t.setData({
                status: 2
            });
        } else if ("isuse" == s) {
            u = l.is_use;
            t.setData({
                status: 3
            });
        } else if ("cart" == s) {
            u = l.info;
            t.setData({
                status: 4
            });
        } else if ("isover" == s) {
            u = l.is_over;
            t.setData({
                status: 5
            });
        } else if ("nouse" == s) {
            u = l.info;
            t.setData({
                status: 6
            });
        } else if ("is_get_hall" == s) {
            var u = l.info;
            t.setData({
                status: 7
            });
        }
        console.log(s), console.log(l), console.log(u);
        for (var g = 0; g < u.length; g++) u[g].id == a && t.setData({
            info: u[g],
            getranges: l.getranges[g].split("、"),
            autoSize: l.autoSize[g],
            ind: g
        });
        o.wxParse("article", "html", t.data.info.use_notice, t, 5), t.setData({
            infoDetail: l,
            money: r
        }), console.log(t.data.info), console.log(t.data.info);
    },
    tel: function(o) {
        var s = this, n = o.currentTarget.dataset.id;
        if ("" == n || void 0 == n) return wx.showToast({
            title: "非法进入",
            icon: "none",
            duration: 2e3
        }), !1;
        a.userGetTicket({
            openid: t.globalData.openid,
            tid: n
        }).then(function(t) {
            if (console.log(t), 0 == t.errno) {
                wx.showToast({
                    title: "领取成功，快去使用吧",
                    icon: "none",
                    duration: 2e3
                });
                var a = getCurrentPages(), o = (a[a.length - 1], a[a.length - 2]), n = "info[" + s.data.ind + "].is_get";
                o.setData(e({}, n, 1)), wx.navigateBack({
                    delta: 1
                });
            } else wx.showToast({
                title: t.message,
                icon: "none",
                duration: 2e3
            });
        });
    },
    use: function(e) {
        var t = e.currentTarget.dataset.couid, a = e.currentTarget.dataset.money, o = getCurrentPages(), s = (o[o.length - 1], 
        o[o.length - 2], o[o.length - 3]), n = s.data, i = parseFloat(n.totalPrices) - parseFloat(a);
        console.log(n.totalPrices), console.log(a), i <= 0 && (i = .01), s.setData({
            coupon: t,
            types: 0,
            mon: parseFloat(a)
        }), wx.navigateBack({
            delta: 2
        });
    },
    btn: function(e) {
        wx.showToast({
            title: "不满足使用要求哦，换一个优惠券吧",
            icon: "none",
            duration: 2e3
        });
    },
    touse: function() {
        wx.navigateTo({
            url: "/pages/template/index"
        });
    }
});